package com.example.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.net.Socket;
import java.nio.file.Files;
import java.nio.file.Paths;


public class ProcessShowCommander {
    public static void processShowCommand(Socket clientSocket, BufferedReader reader) throws IOException {
        String cmd = reader.readLine();
        if (cmd.startsWith("show")) {
            String filePath = cmd.substring(5);
            showFileContent(filePath);
        }
    }
    public static void showFileContent(String filePath) {
        try {
            String fileContent = readFileContent(filePath);
            System.out.println("文件内容：" + fileContent);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static String readFileContent(String filePath) throws IOException {
        return new String(Files.readAllBytes(Paths.get(filePath)));
    }

}
